package sorting;

public class BubbleSort {

	static int[] array = new int[] { 5, 9, 4, 0, 14, 6, 14, 99, 0, 3, 44, 17 };

	public static void main(String[] args) {

		sort(array);
		
		printArray(array);

	}
	
	private static void sort(int[] array) {
		
		for (int i=0; i<array.length; i++) {
			for(int j = array.length - 1; j > i; j--) {
				if(array[j] < array[j-1]) {
					swap(array, j, j-1);
				}
			}
		}
		
	}

	private static void swap(int[] array, int i, int j) {
		int tmp = array[i];
		array[i] = array[j];
		array[j] = tmp;

	}

	private static void printArray(int[] array2) {
		for (int a : array) {
			System.out.print(a + " ");
		}
	}
}
